using System;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Travel.Library
{
    public class DBParams
    {        
        protected const string strConnection = "Dsn=ninhvanbay;uid=root";
        protected OdbcCommand obj_Command = null;
        protected OdbcCommand obj_CommandStore = null;
        protected OdbcConnection obj_Connection = null;
        protected OdbcTransaction obj_Transaction = null;
        protected OdbcDataAdapter obj_DataAdapter = null;
        protected ArrayList obj_Parameters = new ArrayList();
        protected Hashtable obj_Hashtable = null;
        public string[] QueryCollection = new string[1];       
        protected int nCommands = 0;        

        protected DataSet obj_DataSet = new DataSet();
        protected IDataReader obj_IDataReader = null;
        protected DataSet DS = new DataSet();
        protected DataTable obj_DataTable = new DataTable();

        public string[] paramName = null;
        public string[,] paramNames = null;
        public object[] paramValue = null;
        public object[,] paramValues = null;
        public int i_CommandText = 1;
        public int i_StoreProcedure = 2;
        public const int i_Commit = 1;
        public const int i_Rollback = 2;
        public int i_RowCount = 0;
        public object o_Retval = null;
        
        #region Define these constants about Data Type

        protected const int i_Type_BigInt = 1;
        protected const int i_Type_Binary = 2;
        protected const int i_Type_Bit = 3;
        protected const int i_Type_Char = 4;
        protected const int i_Type_DateTime = 5;
        protected const int i_Type_Decimal = 6;
        protected const int i_Type_Numeric = 7;
        protected const int i_Type_Double = 8;
        protected const int i_Type_Image = 9;
        protected const int i_Type_Int = 10;
        protected const int i_Type_NChar = 11;
        protected const int i_Type_NText = 12;
        protected const int i_Type_NVarChar = 13;
        protected const int i_Type_Real = 14;
        protected const int i_Type_UniqueIdentifier = 15;
        protected const int i_Type_SmallDateTime = 16;
        protected const int i_Type_SmallInt = 17;
        protected const int i_Type_Text = 18;
        protected const int i_Type_TimeStamp = 19;
        protected const int i_Type_TinyInt = 20;
        protected const int i_Type_VarBinary = 21;
        protected const int i_Type_VarChar = 22;
        protected const int i_Type_Date = 23;
        protected const int i_Type_Time = 24;

        #endregion

        #region Define these constants about Parameter Direction

        protected const int i_Direction_Input = 1;
        protected const int i_Direction_InputOutput = 2;
        protected const int i_Direction_Output = 3;
        protected const int i_Direction_ReturnValue = 4;

        #endregion

        public DBParams()
        {
               
        }

        public ParameterDirection GetParamDirection(int iDirection)
        {
            switch(iDirection)
            {
                case i_Direction_Input:
                    return ParameterDirection.Input;
                case i_Direction_InputOutput:
                    return ParameterDirection.InputOutput;
                case i_Direction_Output:
                    return ParameterDirection.Output;
                case i_Direction_ReturnValue:
                    return ParameterDirection.ReturnValue;
                default:
                    break;
            }
            return ParameterDirection.ReturnValue;
        }
    }
}
